Add TypeScript types throughout codebase#3
Merged
Conversation
- Add ICacheOptions interface for cache configuration options - Add ICacheMeta interface for cache entry metadata - Update ICacheEntry interface to use generic types - Replace `any[]` with `unknown[]` for function arguments in key strategies - Replace `any` with `unknown` for cache content parameters across all storage implementations - Add IMultiCacheKeyStrategy interface for multi-cache decorator - Add proper type guards in ExpirationStrategy - Update all storage implementations (Memory, FS JSON, LRU, LRU-Redis, NodeCache, Redis, RedisIO) with proper types - Fix test files to use `unknown` instead of `any` for error handling and arguments This improves type safety across the entire codebase by eliminating all `any` types, making the library more robust and easier to maintain.
- Add generic type parameter `<T>` to setItem methods in all interfaces allowing type-safe content storage: `setItem<T>(key, content: T | undefined)` - Update AbstractBaseStrategy and ExpirationStrategy with generic setItem - Update all storage implementations with generic setItem methods - Narrow intermediate deserialization types in Redis storages from `unknown` to more specific union types (e.g., `string | T` during JSON parsing) - Fix test to use explicit union type for mixed content arrays This improves type inference and allows consumers to get compile-time type checking when storing typed data in the cache.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
any[]withunknown[]for function arguments in key strategiesanywithunknownfor cache content parameters across all storage implementationsunknowninstead ofanyfor error handling and argumentsThis improves type safety across the entire codebase by eliminating all
anytypes, making the library more robust and easier to maintain.